package com.dinzeer.slashblade_useful_addon.events;

import com.dinzeer.legendreliclib.lib.util.FastMakeEntityUtil;
import com.dinzeer.slashblade_useful_addon.config.RankConfig;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class RankHandler {
    @SubscribeEvent
    public static void OnHurtEntity(LivingHurtEvent event){
        if (!(event.getSource().getEntity() instanceof LivingEntity entity))return;
        if (RankConfig.RankAddDamage.get()&&!event.getSource().is(DamageTypes.GENERIC_KILL)){
        int rank = SUAevents.getPlayerRank(entity);
        event.setAmount((float) (event.getAmount()+(1+rank*RankConfig.RankAddDamageCount.get())));
        if (RankConfig.RankAddDamageVoidAttack.get()!=0){
            FastMakeEntityUtil.FastHurt(event.getEntity(),entity, (float) (RankConfig.RankAddDamageVoidAttack.get()*1f), DamageTypes.GENERIC_KILL);
        }
        }
    }
}
